package com.shrfid.rfidsdk.tag.uhf;


import com.shrfid.rfidsdk.tag.base.BaseCommand;

public class UHFCommand extends BaseCommand {

    /**
     * ping 命令
     */
    public static final byte[] CMD_PING = {0X01, 0X01};
    /**
     * 盘点指令
     */
    public static final byte[] CMD_INVENTORY = {(byte) 0X01};

    /**
     * 调整功率 命令
     */
    public static final byte[] OPTION_POWER = {0X2F};

    /**
     * 查询配置 命令
     */
    public static final byte[] READ_CONFIG = {0X21};


    public byte[] connectDevice() {
        return new UHFRequestFrame.Builder()
                .address(generateRollCode())
                .cmd(CMD_PING)
                .build()
                .toBytes();
    }


    public byte[] inventory() {
        return new UHFRequestFrame.Builder()
                .address((byte) 0x00)
                .cmd(CMD_INVENTORY)
                .params(new byte[]{0x04, 0x00, 0x00, (byte) 0x80, 0x14})
//                .params(new byte[]{0x04, 0x00, 0x00, (byte) 0x04, 0x04})//0x80是单天线,0x04是双天线(1,3)
                .build()
                .toBytes();
    }


    public byte[] writeAfi(byte[] uid, byte afi) {
        return new byte[0];
    }


    public byte[] optionPower(byte power) {
        return new UHFRequestFrame.Builder()
                .address((byte) 0x00)
                .cmd(OPTION_POWER)
                .params(new byte[]{power})
                .build().toBytes();
    }

    @Override
    public byte[] setEas(byte[] uid) {
        return new byte[0];
    }

    @Override
    public byte[] resetEas(byte[] uid) {
        return new byte[0];
    }

    @Override
    public byte[] selectAntenna(int antenna) {
        return new byte[0];
    }

}
